package org.example.day01;

public class MyThread4 extends Thread{
    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 500000; i++) {
            if(this.isInterrupted()){
                System.out.println("我要推出了");
                break;
            }
            System.out.println("i=" + i);
        }
    }

    public static void main(String[] args) {
        try {
            MyThread4 m4 = new MyThread4();
            m4.start();
            Thread.sleep(2000);
            m4.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end！");
    }
}
